<template>
  <a-card :bordered="false">
    <!-- 抽屉 -->
    <a-drawer title="收稿详情" :width="screenWidth" @close="onClose" :visible="visible">
      <!-- 抽屉内容的border -->
      <div
        :style="{
          padding: '10px',
          border: '1px solid #e9e9e9',
          background: '#fff',
        }"
      >
        <div class="table-page-search-wrapper">
          <a-form layout="inline" :form="form" @keyup.enter.native="searchQuery">
            <a-row :gutter="10">
              <a-col :md="8" :sm="12">
                <a-form-item label="杂志名称"> {{ model.magazineId_dictText }} </a-form-item>
              </a-col>
              <a-col :md="9" :sm="24">
                <a-form-item label="刊期名称" style="width: 170px" :labelCol="labelCol" :wrapperCol="wrapperCol">
                  {{ model.frequencyName }}
                </a-form-item>
              </a-col>
            </a-row>
            <a-row :gutter="10">
              <a-col :md="8" :sm="12">
                <a-form-item label="截稿时间"> {{ model.frequencyEndDate }} </a-form-item>
              </a-col>
              <a-col :md="9" :sm="24">
                <a-form-item label="收稿数量" style="width: 170px" :labelCol="labelCol" :wrapperCol="wrapperCol">
                  {{ model.frequencyQuantity }}
                </a-form-item>
              </a-col>
            </a-row>
          </a-form>
        </div>
        <!-- 操作按钮区域 -->
        <div class="table-operator">
          <a-button type="primary" icon="download" @click="xiazai(kanqiid)">整期下载</a-button>
        </div>
        <div class="table-page-search-wrapper">
          <a-table
            ref="table"
            size="middle"
            :scroll="{ x: true }"
            bordered
            rowKey="id"
            :columns="columns"
            :dataSource="queryParam"
            @change="handleTableChange"
          >
            <span slot="action" slot-scope="text, record">
              <a @click="handleDetail(record)">稿件详情</a>
              <a-divider type="vertical" />
              <a-dropdown>
                <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
                <a-menu slot="overlay">
                  <a-menu-item v-has="'manuscript:retreat'">
                    <a @click="retreat(record)">退修退稿</a>
                  </a-menu-item>
                </a-menu>
              </a-dropdown>
            </span>
          </a-table>
        </div>
      </div>
    </a-drawer>
    <!-- 字典数据 -->
    <manuscript-modal ref="modalForm" @ok="modalFormOk"></manuscript-modal>
    <manuscriptProgresss-modal ref="fff" @ok="handleReplace(record)"></manuscriptProgresss-modal>
  </a-card>
</template>

<script>
import pick from 'lodash.pick'
import { filterObj } from '@/utils/util'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import ManuscriptProgresssModal from './modules/ManuscriptProgresssModal'
import { replaceFilterelement, abstractTheDetails, manuscriptToDownload } from '@api/api'
import ManuscriptModal from './modules/ManuscriptModal'
export default {
  name: 'EquipmentitemList',
  mixins: [JeecgListMixin],
  components: {
    ManuscriptModal,
    ManuscriptProgresssModal,
  },
  data() {
    return {
      columns: [
        {
          title: '稿件名称',
          align: 'center',
          dataIndex: 'manuscriptName',
        },
        {
          title: '稿件状态',
          align: 'center',
          dataIndex: 'manuscriptState_dictText',
        },
        {
          title: '付款状态',
          align: 'center',
          dataIndex: 'paymentState_dictText',
        },
        {
          title: '录入人',
          align: 'center',
          dataIndex: 'createBy',
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          fixed: 'right',
          width: 147,
          scopedSlots: { customRender: 'action' },
        },
      ],
      queryParam: {},
      dataSource: {},
      kanqiid: '',
      title: '操作',
      visible: false,
      screenWidth: 800,
      //设备详情
      model: {},
      //设备id
      id: '',
      status: 1,
      labelCol: {
        xs: { span: 5 },
        sm: { span: 5 },
      },
      wrapperCol: {
        xs: { span: 12 },
        sm: { span: 12 },
      },
      form: this.$form.createForm(this),
      url: {
        list: '/frequency/frequency/list',
        delete: '/frequency/frequency/delete',
        deleteBatch: '/frequency/frequency/deleteBatch',
        exportXlsUrl: '/frequency/frequency/exportXls',
        importExcelUrl: 'frequency/frequency/importExcel',
      },
    }
  },
  created() {
    debugger
    // 当页面初始化时,根据屏幕大小来给抽屉设置宽度
    this.resetScreenSize()
  },
  methods: {
    xiazai(record) {
      console.log(record)
      debugger
      var that = this
      //封装提交到后台的参数
      var param = {}
      //刊期id
      param.frequencyId = that.kanqiid
      manuscriptToDownload(param).then(function (res) {
        debugger
        console.log(res)
        //成功刷新外面的页面
        that.$emit('ok')
      })
      that.loadData()
    },
    submitCallback() {
      debugger
      this.$emit('ok')
      this.visible = false
    },
    add(dictId) {
      debugger
      this.dictId = dictId
      this.edit({})
    },
    edit(record) {
      // debugger
      this.handleReplace(record)
      this.model = Object.assign({}, record)
      this.queryParam = {}
      // 当其它模块调用该模块时,调用此方法加载字典数据
      this.loadData()
      this.visible = false
      this.visible = true
    },
    //查询稿件详情
    handleReplace(record) {
      if (record != undefined) {
        debugger
        var that = this
        //封装提交到后台的参数
        var param = {}
        //刊期id
        param.frequencyId = record.id
        that.kanqiid = record.id
        abstractTheDetails(param).then(function (res) {
          debugger
          that.queryParam = res.result.records

          //成功刷新外面的页面
          that.$emit('ok')
        })
        that.loadData()
      } else {
        var that = this
        //封装提交到后台的参数
        var param = {}
        //刊期id
        param.frequencyId = that.kanqiid
        abstractTheDetails(param).then(function (res) {
          debugger
          that.queryParam = res.result.records
          //成功刷新外面的页面
          that.$emit('ok')
        })
        that.loadData()
      }
    },
    // 添加字典数据
    showDrawer() {
      this.visible = true
    },
    onClose() {
      debugger
      this.visible = false
      this.form.resetFields()
      // this.dataSource = []
    },
    // 抽屉的宽度随着屏幕大小来改变
    resetScreenSize() {
      debugger
      let screenWidth = document.body.clientWidth
      if (screenWidth < 600) {
        this.screenWidth = screenWidth
      } else {
        this.screenWidth = 800
      }
    },
    //update--begin--autor:wangshuai-----date:20191204------for：系统管理 数据字典禁用和正常区别开，添加背景颜色 teambition JT-22------
    //增加样式方法返回值
    getRowClassname(record) {
      debugger
      if (record.status == 0) {
        return 'data-rule-invalid'
      }
    },
    //update--end--autor:wangshuai-----date:20191204------for：系统管理 数据字典禁用和正常区别开，添加背景颜色 teambition JT-22------
  },
}
</script>
<style lang="less" scoped>
//update--begin--autor:wangshuai-----date:20191204------for：系统管理 数据字典禁用和正常区别开，添加背景颜色 teambition JT-22------
/deep/ .data-rule-invalid {
  background: #f4f4f4;
  color: #bababa;
}
//update--begin--autor:wangshuai-----date:20191204------for：系统管理 数据字典禁用和正常区别开，添加背景颜色 teambition JT-22------
</style>